package com.web.products;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.service.ProductsService;
import com.util.AuthenticateHttpServlet;

/**
 * Servlet implementation class ProductDelete
 */
@WebServlet("/Product/Delete")
public class ProductDelete extends AuthenticateHttpServlet {
	private static final long serialVersionUID = 1L;

	protected void post(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		try {
			String productCode = request.getParameter("code");
			ProductsService service = new ProductsService();
			service.deleteProductById(productCode);
		} catch (NumberFormatException ex) {
			ex.printStackTrace();
		}
		request.getRequestDispatcher("/Product/List").forward(request, response);
	}

}
